﻿<UserControl x:Class="uTorrentNetClient.ModelDesign.TorrentProperties.View.PropertiesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
             xmlns:local="clr-namespace:uTorrentNetClient.ModelDesign.Converter"
             mc:Ignorable="d" 
             Height="500" Width="600">
    <UserControl.Resources>
        <local:TimeSpanHoursConverter x:Key="timeSpanConverter"/>
        <local:OptionValueBoolConverter x:Key="optionValueConverter"/>
        <local:FilePriorityDisplayConverter x:Key="filePriorityConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="20" />
            <RowDefinition Height="20" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <!--RowDefinition Height="25" /-->
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />            
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="290" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Grid.ColumnSpan="2">
            <Button Margin="1" Content="x" HorizontalAlignment="Right" Command="{Binding Path=CancelCommand}"/>
        </Border>

        <TextBlock Text="Eigenschaften von " Grid.Row="1" Grid.Column="0" />
        <TextBlock Text="{Binding Path=Torrent.Name}" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" />

        <TextBlock Text="DTH" Grid.Row="2" Grid.Column="0" />
        <CheckBox IsChecked="{Binding Path=Torrent.DHT, Mode=TwoWay, Converter={StaticResource optionValueConverter}}" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right" Margin="3"/>

        <TextBlock Text="PEX" Grid.Row="3" Grid.Column="0" />
        <CheckBox IsChecked="{Binding Path=Torrent.PEX, Mode=TwoWay, Converter={StaticResource optionValueConverter}}" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right" Margin="3"/>

        <TextBlock Text="Max Upload Geschwindigkeit (KB/s)" Grid.Row="4" Grid.Column="0" />
        <TextBox Text="{Binding Path=Torrent.MaximumUploadBytesPerSecond, Mode=TwoWay}" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Stretch" TextAlignment="Right"/>

        <TextBlock Text="Max Download Geschwindigkeit (KB/s)" Grid.Row="5" Grid.Column="0" />
        <TextBox Text="{Binding Path=Torrent.MaximumDownloadBytesPerSecond, Mode=TwoWay}" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Stretch" TextAlignment="Right"/>

        <TextBlock Text="Upload Slots" Grid.Row="6" Grid.Column="0" />
        <TextBox Text="{Binding Path=Torrent.UploadSlots, Mode=TwoWay}" Grid.Column="1" Grid.Row="6" HorizontalAlignment="Stretch" TextAlignment="Right"/>

        <!--TextBlock Text="Initial Seeding" Grid.Row="9" Grid.Column="0" />
        <CheckBox IsChecked="{Binding Path=Torrent.InitialSeeding, Mode=TwoWay, Converter={StaticResource optionValueConverter}}" Grid.Column="1" Grid.Row="9" HorizontalAlignment="Right" Margin="3"/-->

        <TextBlock Text="Standart Überschreiben (Seed)" Grid.Row="7" Grid.Column="0" />
        <CheckBox IsChecked="{Binding Path=Torrent.OverrideQueueing, Mode=TwoWay, Converter={StaticResource optionValueConverter}}" Grid.Column="1" Grid.Row="7" HorizontalAlignment="Right" Margin="3"/>

        <TextBlock Text="Max Seed-Zeit (Stunden)" Grid.Row="8" Grid.Column="0" />
        <TextBox Text="{Binding Path=Torrent.MaximumSeedTime, Mode=TwoWay, Converter={StaticResource timeSpanConverter}}" Grid.Column="1" Grid.Row="8" HorizontalAlignment="Stretch" TextAlignment="Right" IsEnabled="{Binding Path=Torrent.OverrideQueueing, Converter={StaticResource optionValueConverter}}"/>

        <TextBlock Text="Max Seed-Ratio" Grid.Row="9" Grid.Column="0" />
        <TextBox Text="{Binding Path=Torrent.MaximumSeedRatio, Mode=TwoWay}" Grid.Column="1" Grid.Row="9" HorizontalAlignment="Stretch" TextAlignment="Right" IsEnabled="{Binding Path=Torrent.OverrideQueueing, Converter={StaticResource optionValueConverter}}"/>

        <TextBlock Text="Dateien" Grid.Row="10" Grid.ColumnSpan="2"/>
        <dg:DataGrid Grid.Row="11" Grid.ColumnSpan="2" AutoGenerateColumns="False" ItemsSource="{Binding Mode=OneWay, Path=Torrent.Files}" BorderThickness="0" GridLinesVisibility="None" AlternatingRowBackground="Beige" SelectedItem="{Binding Path=SelectedFile}"
                     RowDetailsVisibilityMode="Collapsed" FontSize="11.5" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" VerticalContentAlignment="Center">
            <dg:DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Nicht Herunterladen" Command="{Binding Path=SetFileNoDownloadCommand}" />
                    <MenuItem Header="Hoche Priorität" Command="{Binding Path=SetFileHighCommand}" />
                    <MenuItem Header="Normale Priorität" Command="{Binding Path=SetFileNormalCommand}" />
                    <MenuItem Header="Niedrige Priorität" Command="{Binding Path=SetFileLowCommand}" />
                </ContextMenu>
            </dg:DataGrid.ContextMenu>
            <dg:DataGrid.Columns>
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Name}" Header="Datei" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=TotalFileSize}" Header="Größe" IsReadOnly="True" />
                <dg:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Priority, Converter={StaticResource filePriorityConverter}}" Header="Prorität" IsReadOnly="True" />
            </dg:DataGrid.Columns>
        </dg:DataGrid>

        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="12" Grid.ColumnSpan="2">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Margin="2" Content="OK" Command="{Binding Path=OkCommand}"/>
                <Button Margin="2" Content="Abbrechen" Command="{Binding Path=CancelCommand}"/>
            </StackPanel>
        </Border>

    </Grid>
</UserControl>
